package com.hospital.xiaochengxiu.yang.controller;


import com.alibaba.fastjson.JSON;
import com.hospital.xiaochengxiu.yan.entity.Consumeinfo;
import com.hospital.xiaochengxiu.yang.entity.Queue;
import com.hospital.xiaochengxiu.yang.entity.UserQueue;
import com.hospital.xiaochengxiu.yang.service.ConsumeinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 挂号的控制类
 */
@RestController
@RequestMapping("/api")
public class ConsumeinfoController {
    @Autowired
    private ConsumeinfoService service;

    /**
     * 挂号
     * @param userQueue 挂号的信息对象
     * @return 成功 返回 true
     */
    @RequestMapping("/gh")
    @ResponseBody
    public String checkRegis(UserQueue userQueue) {
        boolean b = service.consumeUser(userQueue);
        return JSON.toJSONString(b);
    }
    /**
     * 根据传的卡号查询出挂号记录信息
     * @return 返回挂号记录信息的集合
     */
    @GetMapping("/registrationrecord/selectByCard/{cardNo}")
    public String selectByCard(@PathVariable Integer cardNo){
        List<Queue> queues = service.selQueue(cardNo);
        return JSON.toJSONString(queues);
    }
}
